#!/usr/bin/env python
#coding=utf-8

import web
from webpy import session

#session.config((r'/tmp/test.1', r'/tmp/test.2',), startServer=False)
session.start()


urls = (
    '/', 'Index',
)


class Index(object):
    def GET(self):
        try:
            session.lock('count')
            if 'count' not in session:
                session['count'] = 1
            else:
                print 'count:', session['count']
                session['count'] += 1
            if session['count'] == 10:
                del session['count']
                session['count'] = 0
            session.unlock('count')
            return session['count']
        except Exception, ex:
            print ex
            return ex            


app = web.application(urls, globals())

if __name__ == "__main__":
    app.run()
